package com.ml.carManager.ui;

import android.os.Bundle;

import androidx.annotation.NonNull;

import com.ml.carManager.ui.login.LoginActivity;
import com.ml.carManager.ui.diver.MainDivierActivity;
import com.ml.carManager.R;
import com.ml.carManager.utils.auth.AuthManager;

import custom.base.ui.activity.AppManager;
import custom.base.ui.activity.BaseActivity;
import custom.base.utils.DelayUtil;
import custom.base.utils.store.PreferencesManager;

public class SplashActivity extends BaseActivity {
    private DelayUtil delayUtil = null;

    @Override
    public int getLayoutID() {
        return R.layout.act_splash;
    }

    @Override
    public void initObject(@NonNull Bundle savedInstanceState) {
        super.initObject(savedInstanceState);
        delayUtil = new DelayUtil();
    }

    @Override
    public void initData(@NonNull Bundle savedInstanceState) {
        super.initData(savedInstanceState);

        delayJump();
    }

    private void delayJump() {
        delayUtil.delay(0, new DelayUtil.OnDelayListener() {
            @Override
            public void onDelayFinish() {
                //是否是第一次进入
                boolean firstEnter = PreferencesManager.getInstance(SplashActivity.this).getBoolean(PreferencesManager.PRE_FIRST_ENTER, true);

//                if (firstEnter) {
//                    startActivity(GuideActivity.class);
//                    AppManager.getInstance().finishAllActivity();
//                } else {
                if (AuthManager.getInstance(SplashActivity.this).isAuth()) {
                    startActivity(MainDivierActivity.class);
                    AppManager.getInstance().finishAllActivity();
                    overridePendingTransition(R.anim.anim_fade_in, R.anim.keep);

                } else {
                    startActivity(LoginActivity.class);
                    AppManager.getInstance().finishAllActivity();
                }
            }

            @Override
            public void onDealing() {

            }
        });
    }

    @Override
    public void onBackPressed() {
//        super.onBackPressed();
    }
}
